<template>
  <div class="mins-1">
    <!-- 图标 -->
    <div class="ico-1">
      <div v-for="i in 3" :key="i" class="img-12"></div>
    </div>
    <div class="text-2">当前直播课程</div>
    <div class="biao-1">
      <!-- 表头 -->
      <div class="baotou-1">
        <div class="d-1">教室</div>
        <div class="d-1">教师</div>
        <div class="d-1">课程名称</div>
      </div>
      <!-- 表内容 -->
      <div class="nei-1">
        <el-carousel
          arrow="never"
          :autoplay="true"
          direction="vertical"
          :pause-on-hover="false"
          :interval="2000"
          indicator-position="none"
          class="luo-1"
        >
          <el-carousel-item
            v-for="(group, groupIndex) in groupedData"
            :key="groupIndex"
            class="luo-2"
          >
            <div
              v-for="(item, index) in group"
              :key="`item-${index}`"
              class="neir-o"
            >
              <div class="t-1">{{ item.id }}</div>
              <div class="t-2">{{ item.cdmc }}</div>
              <div class="t-3">{{ item.name }}</div>
              <div class="t-4">{{ item.kcmc }}</div>
            </div>
          </el-carousel-item>
        </el-carousel>
      </div>
    </div>
    <div class="text-2">最近访问人数</div>
    <div class="biao-1">
      <!-- 表头 -->
      <div class="baotou-11">
        <div class="d-1">用户</div>
        <div class="d-1">单位</div>
        <div class="d-1">课程名称</div>
        <div class="d-1">时间</div>
      </div>
      <!-- 表内容 -->
      <div class="nei-11">
        <el-carousel
          arrow="never"
          :pause-on-hover="false"
          :autoplay="true"
          direction="vertical"
          :interval="2000"
          indicator-position="none"
          class="luo-1"
        >
          <el-carousel-item
            v-for="(group, groupIndex) in groupedData1"
            :key="groupIndex"
            class="luo-2"
          >
            <div
              v-for="(item, index) in group"
              :key="`item-${index}`"
              class="neir-o"
            >
              <div class="t-1">{{ item.id }}</div>
              <div class="t-2">{{ item.name }}</div>
              <div class="t-3">{{ item.dwmc }}</div>
              <div class="t-4">{{ item.kcmc }}</div>
              <div class="t-4">{{ item.update_time }}</div>
            </div>
          </el-carousel-item>
        </el-carousel>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref, onMounted, computed } from 'vue'
import { getVideoCourse, getVideoPerson } from '@/services/index'
import type { arr2, arr3 } from '@/types'
import dayjs from 'dayjs'
const Larr = ref<arr2>([]) //当前直播课程
const Larr1 = ref<arr3>([]) //最近访问人数
const list = async () => {
  const res = await getVideoCourse()
  Larr.value = res.data
  console.log(res.data) //这个里是数据
}
const list1 = async () => {
  const res = await getVideoPerson()
  Larr1.value = res.data
  console.log(res.data) //这个里是数据
}

onMounted(async () => {
  list()
  list1()
})
const groupedData = computed(() => {
  const groups = []
  for (let i = 0; i < Larr.value.length; i += 4) {
    groups.push(Larr.value.slice(i, i + 4))
  }
  return groups
})
const processedData = computed(() => {
  return Larr1.value.map((item) => {
    const time = dayjs(item.update_time)
    return { ...item, update_time: time.format('HH:mm:ss') }
  })
})
const groupedData1 = computed(() => {
  const groups = []
  for (let i = 0; i < processedData.value.length; i += 4) {
    groups.push(processedData.value.slice(i, i + 4))
  }
  return groups
})
</script>

<style lang="scss" scoped>
.mins-1 {
  width: 650px;
  height: 420px;
  background-image: url('../../assets/img/z-1.png');
  background-repeat: no-repeat;
  background-size: 100% 100%;
  padding: 10px;
  margin: 0 5px;
  .ico-1 {
    display: flex;
    .img-12 {
      width: 200px;
      height: 20px;
      background-image: url('../../assets/img/t-1.gif');
      background-repeat: no-repeat;
      background-size: 100% 100%;
      margin: 0 3px;
      margin-bottom: 10px;
    }
  }
  .text-2 {
    width: 140px;
    height: 35px;
    color: rgb(255, 255, 255);
    font-weight: bold;
    font-family: 'Microsoft Yahei', Arial, 'sans-serif';
    font-size: 18px;
    text-align: center;
    line-height: 35px;
    text-overflow: ellipsis;
    white-space: nowrap;
    background-image: url('../../assets/img/xa-1.png');
    background-repeat: no-repeat;
    background-size: 100% 100%;
    margin-bottom: 10px;
  }
  .biao-1 {
    width: 600px;
    height: 125px;
    border: 1px solid #fff;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    padding: 10px;
    margin-bottom: 10px;

    .baotou-1 {
      display: flex;
      justify-content: space-around;
      width: 100%;
      height: 20px;
      .d-1 {
        width: 100px;
        height: 20px;
        color: #fff;
        text-align: center;
        font-size: 14px;
      }
    }
    .baotou-11 {
      display: flex;
      justify-content: space-evenly;
      width: 100%;
      height: 20px;
      .d-1 {
        width: 100px;
        height: 20px;
        color: #fff;
        text-align: center;
        font-size: 14px;
      }
    }
    .nei-1 {
      width: 600px;
      height: 104px;
      // position: relative;
      // background: red;
      .neir-o {
        display: flex;
        width: 100%;
        will-change: transform;
        .t-1 {
          width: 20px;
          height: 20px;
          border-radius: 50%;
          background: #f4ff00;
          color: #000;
          text-align: center;
          margin: 3px 10px;
          font-size: 14px;
        }
        .t-2 {
          width: 100px;
          height: 20px;
          color: #fff;
          text-align: center;
          margin: 3px 10px;
          font-size: 14px;
          white-space: nowrap; /* 禁止换行 */
          overflow: hidden; /* 溢出隐藏 */
          text-overflow: ellipsis; /* 文本溢出时显示省略号 */
        }
        .t-3 {
          width: 100px;
          height: 20px;
          color: #fff;
          text-align: center;
          margin: 3px 95px 3px 90px;
          font-size: 14px;
          white-space: nowrap; /* 禁止换行 */
          overflow: hidden; /* 溢出隐藏 */
          text-overflow: ellipsis; /* 文本溢出时显示省略号 */
        }
        .t-4 {
          width: 100px;
          height: 20px;
          color: #fff;
          text-align: center;
          margin: 3px 5px;
          font-size: 14px;
          white-space: nowrap; /* 禁止换行 */
          overflow: hidden; /* 溢出隐藏 */
          text-overflow: ellipsis; /* 文本溢出时显示省略号 */
        }
      }
      .luo-1 {
        width: 100%;
        height: 104px;
        //  background: rgb(0, 255, 55);
      }
      .luo-2 {
        width: 100%;
        height: 104px;
        // background: rgb(0, 255, 55);
      }
    }
    .nei-11 {
      width: 600px;
      height: 104px;
      // position: relative;
      // background: red;
      .neir-o {
        display: flex;
        width: 100%;
        will-change: transform;
        .t-1 {
          width: 20px;
          height: 20px;
          border-radius: 50%;
          background: #f4ff00;
          color: #000;
          text-align: center;
          margin: 3px 10px;
          font-size: 14px;
        }
        .t-2 {
          width: 100px;
          height: 20px;
          color: #fff;
          text-align: center;
          margin: 3px 0;
          font-size: 14px;
        }
        .t-3 {
          width: 100px;
          height: 20px;
          color: #fff;
          text-align: center;
          margin: 3px 36px 3px 40px;
          font-size: 14px;
        }
        .t-4 {
          width: 100px;
          height: 20px;
          color: #fff;
          text-align: center;
          margin: 3px 34px 0 5px;
          font-size: 14px;
          white-space: nowrap; /* 禁止换行 */
          overflow: hidden; /* 溢出隐藏 */
          text-overflow: ellipsis; /* 文本溢出时显示省略号 */
        }
      }
      .luo-1 {
        width: 100%;
        height: 104px;
        //  background: rgb(0, 255, 55);
      }
      .luo-2 {
        width: 100%;
        height: 104px;
        // background: rgb(0, 255, 55);
      }
    }
  }
}
</style>
